<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('月评价结果列表')"/>
</head>
<body class="pear-container">
<div class="layui-card">
    <div class="layui-card-body">
        <table id="viewselfscore-table" lay-filter="viewselfscore-table"></table>
    </div>
</div>
</body>

<script type="text/html" id="viewselfscore-type">
    {{#if (d.dataState == '0') { }}
    <span class="layui-badge layui-bg-orange">开启</span>
    {{# }else if(d.dataState == '-1'){ }}
    <span class="layui-badge layui-bg-blue">关闭</span>
    {{# } }}
</script>

<th:block th:include="include :: footer"/>
<script th:inline="javascript" type="text/javascript">

    /*<![CDATA[*/
    var taskId = /*[[${taskId}]]*/ 20;
    /*]]>*/

    console.log(taskId);

    layui.use(['table', 'form', 'jquery'], function () {
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;
        var laydate = layui.laydate;

        var MODULE_PATH = rootPath + "/MonthSupplytaskController/";
        var cols = [
            [
                // {title: '所属分公司', field: 'orgnization', align: 'center', width: 150},
                //
                // {title: '任务年月', field: 'taskMonth', align: 'center', width: 150},
                //
                // {title: '供电所名称', field: 'supplyName', align: 'center', width: 150},
                //
                // {
                //     field: 'star', title: '供电所星级', align: 'center', width: 150, templet: function (res) {
                //         if (res.star == '1') {
                //             return '一星';
                //         } else if (res.star == '2') {
                //             return '二星';
                //         } else if (res.star == '3') {
                //             return '三星';
                //         } else if (res.star == '4') {
                //             return '四星';
                //         } else if (res.star == '5') {
                //             return '五星';
                //         } else {
                //             return '';
                //         }
                //     }
                // },

                {title: '自评分总分(未加权)', field: 'totalMark', align: 'center', width: 170},

                {title: '自评分总分(权重计算)', field: 'totalScore', align: 'center', width: 170},

                {
                    field: 'isNeccessary', title: '必备条件是否合格', align: 'center', width: 150, templet: function (res) {
                        if (res.isNeccessary == '0') {
                            return '否';
                        } else if (res.isNeccessary == '1') {
                            return '是';
                        } else if (res.isNeccessary == '2') {
                            return '填报中';
                        }
                    }
                },
                {
                    title: '一、营销服务', field: 'yingxiaoScore', align: 'center', width: 150, templet: function (res) {
                        return redline(res.yingxiaoScore, res.star)
                    }
                },

                {
                    title: '二、运维抢修', field: 'yunjianScore', align: 'center', width: 150, templet: function (res) {
                        return redline(res.yunjianScore, res.star)
                    }
                },

                {
                    title: '三、安全管理', field: 'anquanScore', align: 'center', width: 150, templet: function (res) {
                        return redline(res.anquanScore, res.star)
                    }
                },

                {
                    title: '四、党建及队伍建设', field: 'dangjianScore', align: 'center', width: 150, templet: function (res) {
                        return redline(res.dangjianScore, res.star)
                    }
                },

                {
                    title: '五、数字化转型', field: 'shuzihuaScore', align: 'center', width: 150, templet: function (res) {
                        return redline(res.shuzihuaScore, res.star)
                    }
                },

                {
                    title: '六、发展规划', field: 'fazhanScore', align: 'center', width: 150, templet: function (res) {
                        return redline(res.fazhanScore, res.star)
                    }
                },

                {
                    title: '七、“五小建设及基础保障”', field: 'wuxiaoScore', align: 'center', width: 150, templet: function (res) {
                        return redline(res.wuxiaoScore, res.star)
                    }
                },

            ]
        ]

        //table表单列表
        table.render({
            elem: '#viewselfscore-table',
            url: MODULE_PATH + 'list4currentScore/' + taskId,
            page: false,
            method: 'get',
            cols: cols,
            skin: 'line',
            toolbar: '#viewselfscore-toolbar',
            defaultToolbar: [{
                layEvent: 'refresh',
                icon: 'layui-icon-refresh',
            }]
        });

        // 定义函数
        function redline(score, star) {
            console.log(score);
            var target = '';
            if (star == 5) {
                target = 90
            } else if (star == 4) {
                target = 85
            } else if (star == 3) {
                target = 80
            }
            if (score !== null && score !== "" && score !== "null") {
                if (score < target) {
                    return '<a class=""style="color:#ed2a4a">' + score + '</a>';
                } else {
                    return score;
                }
            } else {
                return "";
            }

        }

        //table工具栏绑定
        table.on('toolbar(viewselfscore-table)', function (obj) {
            if (obj.event === 'add') {
                window.add();
            } else if (obj.event === 'refresh') {
                window.refresh();
            } else if (obj.event === 'batchRemove') {
                window.batchRemove(obj);
            }
        });


        //刷新按钮
        window.refresh = function () {
            table.reload('viewselfscore-table');
        }
    })


</script>
</html>